package tools.beans;

import entities.Category;
import entities.Event;
import entities.User;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import managers.EntityManagerAux;


public class InitDB extends HttpServlet {

    @EJB
    private EntityManagerAux ar;

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        String nom;
            String admin;
            String mail;
            String name;
            String pass;
            String phone;
            String surname;

            //ADMINS

            admin = "Jeff";
            mail = "jgineste@etu.enseeiht.fr";
            name = "Gineste";
            pass = "poney";
            phone = "0606060606";
            surname = "Jean-François";

            ar.addAdmin(admin, mail, name, ar.encode(pass), phone, surname);
            
            

        request.setAttribute("message", "ADMIN CREE.");
        request.getRequestDispatcher("index.html").forward(request, response);
        

    } 

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    } 

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }

    @Override
    public String getServletInfo() {
        return "test";
    }

}